#include <SFML/Network.hpp>
#include <iostream>

void DoServerUDP(unsigned short Port)
{
    sf::SocketUDP Server;

    if (!Server.Bind(Port))
        return;

	while (true)
	{
		sf::IPAddress ClientAddress;
		unsigned short ClientPort;
		sf::Packet	rcv;
		std::string Message;
		if (Server.Receive(rcv, ClientAddress, ClientPort) != sf::Socket::Done)
			return;
		rcv >> Message;
		std::cout << "Message received from " << ClientAddress << " on port " << ClientPort
				  << ": \"" << Message << "\"" << std::endl;
		sf::Packet	send;
		send << "I received your request";
		if (Server.Send(send, ClientAddress, ClientPort) != sf::Socket::Done)
			return ;
	}
    Server.Close();
}

int	main()
{
	DoServerUDP(2011);
	return (0);
}